#include <iostream>
#include <unistd.h>
#include <kotf/kotf.hpp>

using namespace std;

kotf::State world_st;
void world(kotf::Stream& stream)
{
    kotf::Scope local(stream, world_st);
    cout << "world() was called" << endl;
    usleep(1000);
}


kotf::State hello_st;
void hello(kotf::Stream& stream)
{
    kotf::Scope local(stream, hello_st);
    
    cout << "hello() was called" << endl;

    world(stream);
}


int main()
{
    kotf::Session sess("hello");
    
    hello_st = sess.getState("hello");
    world_st = sess.getState("world");
    
    kotf::Stream& mainStream = sess.getStream("main");
    mainStream.start();
    hello(mainStream);
    mainStream.finish();
}
